//
//  OilPriceListCell.m
//  Base_App
//
//  Created by Yutian Duan on 2019/6/24.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "OilPriceListCell.h"

@implementation OilPriceListCell

- (void)awakeFromNib {
  [super awakeFromNib];
  // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  [super setSelected:selected animated:animated];
  
  // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  if (self) {
    [self createViews];
  }
  return self;
}

- (void)createViews {
  
  _logoImageView = [[UIImageView alloc] init];
  [self.contentView addSubview:_logoImageView];
  
  _dieselLabel = [[UILabel alloc] init];
  _dieselLabel.numberOfLines = 2;
  _dieselLabel.textAlignment = NSTextAlignmentCenter;
  _dieselLabel.font = [UIFont systemFontOfSize:13.0f];
  [self.contentView addSubview:_dieselLabel];
  
  _gasolineLabel = [[UILabel alloc] init];
  _gasolineLabel.numberOfLines = 2;
  _gasolineLabel.textAlignment = NSTextAlignmentCenter;
  _gasolineLabel.font = _dieselLabel.font;
  [self.contentView addSubview:_gasolineLabel];
  
  _otherGasolineLabel = [[UILabel alloc] init];
  _otherGasolineLabel.numberOfLines = 2;
  _otherGasolineLabel.textAlignment = NSTextAlignmentCenter;
  _otherGasolineLabel.font = _dieselLabel.font;
  [self.contentView addSubview:_otherGasolineLabel];
  
  [_logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.leading.mas_equalTo(self.contentView.mas_leading).offset(30);
    make.top.mas_equalTo(self.contentView.mas_top).offset(10);
    make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-10);
    make.width.mas_equalTo(self.logoImageView.mas_height);
  }];
  
  
  
  [_dieselLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.leading.mas_equalTo(self.logoImageView.mas_trailing).offset(30);
    make.top.bottom.mas_equalTo(self.contentView);
    make.trailing.mas_equalTo(self.gasolineLabel.mas_leading);
    make.width.mas_equalTo(@[self.gasolineLabel, self.otherGasolineLabel]);
  }];
  
  [_gasolineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.bottom.width.mas_equalTo(self.dieselLabel);
    make.trailing.mas_equalTo(self.otherGasolineLabel.mas_leading);
  }];
  
  [_otherGasolineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.bottom.mas_equalTo(self.dieselLabel);
    make.trailing.mas_equalTo(self.contentView.mas_trailing).offset(-30);
  }];
  

}

- (void)setupData {
 
  _logoImageView.image = [UIImage imageNamed:@"caltex"];
  _dieselLabel.text = [NSString stringWithFormat:@"%@\n%@",@"柴油",@"HKD 11.42"];

  _gasolineLabel.text = [NSString stringWithFormat:@"%@\n%@",@"黄金汽油",@"HKD 11.42"];
  
  _otherGasolineLabel.text = [NSString stringWithFormat:@"%@\n%@",@"白金汽油",@"HKD 11.42"];
}

@end

